/*
* @(#) PrintDigit.java 2018年02月23日
*
* Copyright 2010 NetEase.com, Inc. All rights reserved.
*/
package com.leo.m1802.d23;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 *
 * @author xuexiaolei
 * @version 2018年02月23日
 */
public class PrintDigit {
    static AtomicInteger a = new AtomicInteger(0);
    public static void main(String[] args) {
        ExecutorService exec = Executors.newFixedThreadPool(3);
        exec.submit(new PrintTask(1));
        exec.submit(new PrintTask(2));
        exec.submit(new PrintTask(3));
    }

    static class PrintTask implements Runnable{
        int threadName;
        PrintTask(int threadName){
            this.threadName = threadName;
        }
        public void run() {
            while (a.get()<75){
                if (a.get()/5%3 == threadName-1) {
                    System.out.println("线程" + threadName + ":" + a.incrementAndGet());
                }
            }
        }
    }
}
